package com.hualan.servlet;

import com.alibaba.fastjson.JSON;
import com.hualan.service.impl.ShopServiceDaoImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

@WebServlet("/shop/querySearchShopList")
public class ShopListServlet extends HttpServlet {
    private ShopServiceDaoImpl shopService = new ShopServiceDaoImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("进入....");
        //设置字符和返回值类型
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");

        //获取数据
        String keyword = req.getParameter("keyword");
        String phone = req.getParameter("phone");
        Integer pageNum = Integer.valueOf(req.getParameter("pageNum"));
        Integer size = Integer.valueOf(req.getParameter("pageSize"));
        String startTime = req.getParameter("startTime");
        String endTime = req.getParameter("endTime");

        //调用service
        Map<String, Object> map = shopService.selectPage(keyword, phone, startTime, endTime, pageNum, size);
        System.out.println("map = " + map.toString());
	    
	    System.out.println(map);
        //返回前端
        resp.getWriter().write(JSON.toJSONString(map));
    }
}
